<?php

include_once 'dbtable.php';

function get_all_activity(pager $page, $url) {
    $sql = "select nhaunhet.*,user.* from nhaunhet,user where nhaunhet.user_id = user.id order by nhaunhet.id desc";
    return DbTable::Paging($page, $sql, $url,15);
}
function get_act_by_id($id) {
    $sql = "select nhaunhet.*,user.* from nhaunhet,user where nhaunhet.user_id = user.id and nhaunhet.id = '{$id}'  order by nhaunhet.id desc";
    return DbTable::getData($sql);
}
function get_act_to_left_bar() {
    $sql = "select nhaunhet.*,user.* from nhaunhet,user where nhaunhet.user_id = user.id order by nhaunhet.id desc limit 0,5";
    return DbTable::getData($sql);
}
function them_moi_activity($array) {
    if (DbTable::insert("nhaunhet", $array)) {
        return true;
    }
    return false;
}

function sua_activity($array, $id) {
    if (DbTable::update("nhaunhet", $array, $id)) {
        return true;
    }
    return false;
}
function xoa_activity($id) {
    if(DbTable::delete("nhaunhet", $id)){
        return true;
    }
    return false;
}
//josn
function get_activity_by_id_to_edit($id) {
    $sql = "select * from nhaunhet where id = '{$id}'";    
    return DbTable::JsonEncode($sql);
}

?>
